﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WiTeach.Common.template
{
    /// <summary>
    /// CatalogHeader.xaml 的交互逻辑
    /// </summary>
    public partial class CatalogHeader : Page
    {
        public CatalogHeader()
        {
            InitializeComponent();
        }

        private void backHomeButton_Click(object sender, RoutedEventArgs e)
        {
            Frame pageFrame = null;
            DependencyObject currParent = VisualTreeHelper.GetParent(this);
            while (currParent != null && pageFrame == null)
            {
                pageFrame = currParent as Frame;
                currParent = VisualTreeHelper.GetParent(currParent);
            }
            DockPanel currPage = (DockPanel)currParent;
            currPage.Opacity = 0;
            // Change the page of the frame.
            if (pageFrame != null)
            {

                NavigationService.GetNavigationService(this).Navigate(new Uri("/WiTeach;component/DirectorySystem/View/Directory.xaml", UriKind.Relative));
                //pageFrame.Source = new Uri("/WiTeach;component/DirectorySystem/View/Directory.xaml", UriKind.Relative);
            }

            //DockPanel currPage = (DockPanel)this.Parent;
            //currPage.Visibility = System.Windows.Visibility.Hidden;

            //NavigationService.GetNavigationService(this).Navigate(new Uri("/WiTeach;component/DirectorySystem/View/Directory.xaml", UriKind.Relative));
            //Frame pageFrame = null;
            //DependencyObject currParent = VisualTreeHelper.GetParent(this);
            //while (currParent != null && pageFrame == null)
            //{
            //    pageFrame = currParent as Frame;
            //    currParent = VisualTreeHelper.GetParent(currParent);
            //}
            //// Change the page of the frame.
            //if (pageFrame != null)
            //{
            //    pageFrame.Source = new Uri("/WiTeach;component/DirectorySystem/View/Directory.xaml", UriKind.Relative);
            //}
            //Frame parentFrame = null;
            //DependencyObject Parent = VisualTreeHelper.GetParent(pageFrame);
            //while (Parent != null && parentFrame == null)
            //{
            //    parentFrame = currParent as Frame;
            //    Parent = VisualTreeHelper.GetParent(parentFrame);
            //}
            //// Change the page of the frame.
            //if (Parent != null)
            //{
            //    this.NavigationService.Navigate(new Uri("/WiTeach;component/DirectorySystem/View/Directory.xaml", UriKind.Relative));
            
            //    //Parent.Source = new Uri("/WiTeach;component/DirectorySystem/View/Directory.xaml", UriKind.Relative);
            //}

            ////this.NavigationService.Navigate(new Uri("/WiTeach;component/DirectorySystem/View/Directory.xaml", UriKind.Relative));
            
            ////MainWindow mainwindow = new MainWindow();
            ////mainwindow.containerFrame.Source = new Uri("/WiTeach;component/LoginManagement/View/Login.xaml", UriKind.Relative);
            ////mainwindow.Show();
            ////Window win = (Window)this.Parent;
            ////win.Hide();

           
            ////MainWindow mainWindow = new MainWindow();
            ////Console.WriteLine("source1==="+mainWindow.containerFrame.Source.ToString());
            ////mainWindow.containerFrame.Source = new Uri("CourseManagement/View/CourseIndex.xaml", UriKind.Relative);
            ////Console.WriteLine("source2===" + mainWindow.containerFrame.Source.ToString());
            //// 返回主目录
            
        }
    }
}
